<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to MEF</title>
<link href="view/css/demo_page.css" type="text/css" rel="stylesheet"/>
<link href="view/css/demo_table.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
.top, .bottom {
    background-color: #333;
    border: 0px solid #CCCCCC;
}
.headings{  height:38px; padding:0px 16px; background:url(images/box.png) repeat-x; border-radius:6px 6px 0px 0px;}
.tableheading{  height:38px; padding:0px 7px; background:#EFEFEF; border-left:1px solid #DDDDDD; }
.user_info{ margin:10px 30px 0px 30px; border:1px solid #DBDBDB; border-radius:6px 6px 0px 0px; }
.user_norrow{ height:35px; }
.user_norrow td{ padding-left:7px;  border-right:1px solid #DDDDDD; border-bottom:1px solid #DDDDDD; }
.mainusertable{ width:98%; margin:15px 15px 0px 15px; border-left:1px solid #DDDDDD;}
.paglistnums { border-top:1px solid #DDDDDD; display:inline-block; width:100%; height:24px; margin-top:25px; padding-top:13px; }
.paglistnums .pagresults {float: right; padding-right:20px; font-size:12px; }

</style>
<link href="view/css/mefstylesheet.css" type="text/css" rel="stylesheet"/>
</head>
<?php echo $header; ?>
<script type="text/javascript" src="view/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
			$(document).ready(function() {
				$('#sTable').dataTable();
			} );
</script>

<form name="frmCheckin" action="" method="POST">
<div class="user_info">
<input type="button" id="delId" name="delId" value="Delete" onclick="delUser()"/>
<input type="hidden" id="hdelId" name="hdelId" value=""/>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="sTable" width="100%" class="mainusertable">
	<thead class="tableheading">
		<tr height="40">
			<th><input type='checkbox' id='chec1[]' name='chec1' value="<? echo $userid ?>" onclick="selectAll()"/>CheckAll</th>
			<th>S.No</th>
			<th>User Name</th>
			<th>Father's Name</th>
			<th>Contact</th>
			<th>City</th>
			<th>Refereed by</th>
			<th>&nbsp;</th>
			<th>&nbsp;</th>
			<th>&nbsp;</th>
			<th>&nbsp;</th>
		</tr>
	</thead>
	<tbody>
	<?php foreach ($userdata as $key => $patientinfo) { $userid=$patientinfo['p_id'];  ?>
		<tr class="odd gradeX">
			<td><input type='checkbox' id='chec' name='chec' value="<? echo $userid ?>" /></td>
			<td><? echo $key+1; ?></td>
			<td><?php echo $patientinfo["name"]?></td>
			<td><?php echo $patientinfo["fathername"]?></td>
			<td><?php echo $patientinfo["mobile"]?></td>
			<td><?php echo $patientinfo["city"]?></td>
			<td><?php echo $patientinfo["refereed"]?></td>
			<td class="center"><a href="<?php echo $regurl.'&uid='.base64_encode($patientinfo["p_id"]).'&view=1'; ?>"><input class="editbtn" type="button" value="View"></a></td>
			<td class="center"><a href="<?php echo $regurl.'&uid='.base64_encode($patientinfo["p_id"]).'&edit=1'; ?>"><input class="editbtn" type="button" value="Edit"></a></td>
			<td class="center"><a href="<?php echo $envurl.'&uid='.base64_encode($patientinfo["p_id"]).'&before=1'; ?>"><input class="bfrbtn" type="button" value="Before"></a></td>
			<td class="center"><a href="<?php echo $envurl.'&uid='.base64_encode($patientinfo["p_id"]).'&after=1'; ?>"><input class="afrbtn" type="button" value="After"></a></td>
		</tr>
	<?php } ?>
	</tbody>
	
</table>
</div>
</form>
<?php echo $footer;?>
</body>
</html>
<script>
$(document).ready(function() {
	$("#chec").click(function(){
    if(document.getElementById('chec1[]').checked==true)
			{
			document.getElementById('chec1[]').checked=false;
			}	
});
});
function selectAll()
{
	if(document.getElementById('chec1[]').checked)
	{
		$("INPUT[type='checkbox']").attr('checked',true);
		
	}	
	else
	{
		$("INPUT[type='checkbox']").attr('checked',false); 
	}
}
function delUser()
{
		var iselect=""; 
		var che=document.getElementsByTagName("INPUT");
		var len=che.length;
		var cnt = 0;
		for(var i=0;i<len;i++)
		{
			if(che[i].name=="chec")
			{
				if(che[i].checked)
				{
					iselect+=che[i].value+ ",";
					cnt++;
					
				}
			}
		}//alert(iselect); return false;
		if(cnt == 0) {
			alert('Please select the row to delete')
		} else {
			if(confirm("Are you sure want to delete selected rows"))
			{
				$("#hdelId").val(iselect);
				document.frmCheckin.submit();	
			}
		}
}
</script>
